﻿// =================================================================== 
// 数据访问层(GDIT.DAL)
//====================================================================
// 文件：DCounter.cs
// 项目名称：学院网站
// 创建时间：2012-08-08
// 负责人：ChenZhiGang
//引用DevExpress.Data.Filtering，DevExpress.Xpo程序集
// 程序集介绍：公告文章信息数据访问层
// ===================================================================
using GDIT.Model;
using DevExpress.Data.Filtering;
using DevExpress.Xpo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GDIT.Pattern;

namespace GDIT.DAL
{
    public class DCounter : ICounter
    {

        private XpoHelper.Test<Mtb_Counter> userOperation = null;

        /// <summary>
        /// 增加网站被访问的记录数
        /// </summary>
        public int AddCounter()
        {
            userOperation = new XpoHelper.Test<Mtb_Counter>();
            XPCollection xp = userOperation.Operation("OID",1);
            foreach (Mtb_Counter b in xp)
            {
                b.Counter = b.Counter + 1;
                XpoHelper.SaveModified(b);
                return 1;
            }
            return 0;
        }

        /// <summary>
        /// 查询网站被访问的记录数
        /// </summary>
        /// <returns>网站被访问的记录数</returns>
        public int SelectCounter()
        {
            int result = 0;
            userOperation = new XpoHelper.Test<Mtb_Counter>();
            XPCollection xp = userOperation.Operation("OID", 1);
            foreach (Mtb_Counter b in xp)
            {
                result = b.Counter;
            }
            return result;
        }
    }
}
